#pragma once

namespace JHCPP
{
	namespace designpattern
	{
		template <typename T>
		class TAbstractInstantiator
		{
		public:
			TAbstractInstantiator()
			{
			}

			virtual ~TAbstractInstantiator()
			{
			}

			virtual T* createInstance() const = 0;

		private:
			TAbstractInstantiator(const TAbstractInstantiator&);
			TAbstractInstantiator& operator = (const TAbstractInstantiator&);
		};

		template <class T, class Base>
		class TInstantiator: public TAbstractInstantiator<Base>
		{
		public:
			TInstantiator()
			{
			}

			virtual ~TInstantiator()
			{
			}

			Base* createInstance() const
			{
				return new T;
			}
		};
	}//end of namespace DESIGNPATTERN
}//end of namespace JHCPP
